package main.java.dal.valueobject;

public abstract class ValueObject {
    
    protected long id;
    protected String name;
    
    public ValueObject() {
	super();
    }
    
    public ValueObject(long id, String name) {
	this.id = id;
	this.name = name;
    }
    
    /**
     * @return the id
     */
    public long getId() {
	return id;
    }
    
    /**
     * @param id
     *            the id to set
     */
    public void setId(long id) {
	this.id = id;
    }
    
    /**
     * @return the name
     */
    public String getName() {
	return name;
    }
    
    /**
     * @param name
     *            the name to set
     */
    public void setName(String name) {
	this.name = name;
    }
    
    @Override
    public String toString() {
	return String.format("ValueObject [id=%s, name=%s]", id, name);
    }
    
    /*
     * (non-Javadoc)
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode() {
	final int prime = 31;
	int result = 1;
	result = prime * result + (int) (id ^ (id >>> 32));
	result = prime * result + ((name == null) ? 0 : name.hashCode());
	return result;
    }
    
    /*
     * (non-Javadoc)
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
	if (this == obj) {
	    return true;
	}
	if (obj == null) {
	    return false;
	}
	if (!(obj instanceof ValueObject)) {
	    return false;
	}
	ValueObject other = (ValueObject) obj;
	if (id != other.id) {
	    return false;
	}
	if (name == null) {
	    if (other.name != null) {
		return false;
	    }
	} else if (!name.equals(other.name)) {
	    return false;
	}
	return true;
    }
    
}
